<template>
    <div class="">
      <el-container>
        <el-aside width="200px">
          <MinisterMenu></MinisterMenu>
        </el-aside>

        <el-main style="padding:0px">
          <el-row>
            <el-col :span="8"><h2>提交申请</h2></el-col>
          </el-row>
<!--列表-->
          <el-table :height="600" :data="projectList" style="width: 100%">
            <el-table-column label="序号 " type="index" />
            <el-table-column label="项目名字" prop="name" />
            <el-table-column label="项目详情" prop="details" />
            <el-table-column label="发布时间" prop="pubTime" />
            <el-table-column label="开始时间" prop="startTime" />
            <el-table-column label="预计结束时间" prop="estTime" />
            <el-table-column align="right">
              <template #header>
                <el-input @keyup.enter="searchKeyword" v-model="keyword" size="small" placeholder="搜索查询项目名字关键字" />
              </template>
              <template #default="scope">
                <el-button size="small" @click="submit(scope.$index, scope.row)"
                >提交</el-button
                >
<!--                <el-button-->
<!--                    size="small"-->
<!--                    type="danger"-->
<!--                    @click="handleDelete(scope.$index, scope.row)"-->
<!--                >Delete</el-button-->
<!--                >-->
              </template>
            </el-table-column>
          </el-table>
        </el-main>
      </el-container>
       
    </div>  
</template>

<script>
import MinisterMenu from '@/components/menu/MinisterMenu.vue'
import instanceToken from "@/utlis/tokenIdentify";
export default {
    name:'SubmitProjectView',
    components: {
      MinisterMenu,
    },
    data() {
        return {
           keyword:'',
          companyUserId:'',
           projectId:'',
          projectList:[],
        };
    },
    methods: {
      initData(){
        instanceToken.get("/project/minister/noSubmitProject",{params:{
             keyword:this.keyword,
          }}).then(res=>{
            console.log(res.data.data)
          this.projectList = res.data.data;
        })
      },
      searchKeyword(){
        this.initData();
      },
      submit(index,row){
        this.projectId = row.id;
        instanceToken.get("/project/minister/submitProject",{params:{
            companyUserId:this.companyUserId,
            projectId:this.projectId,
          }}).then(res=>{
            console.log(res.data.message)
          if(res.data.message=="可以提交"){
            // window.location.reload();
            this.$message({
              message: '提交成功',
              type: 'success'
            });
            this.projectList.splice(index,1);
          }else{
            this.$message({
              message: '存在未提交的任务，提交失败',
              type: 'error'
            });
          }
        })
      }
    },
    created() {
        this.initData();
        this.companyUserId = window.sessionStorage.getItem("companyUserId");
    },
    computed: {},
    watch: {},
    }
</script>
<style  scoped>

</style>